package com.wjhs.chapter2;

import java.util.ArrayList;
import java.util.List;

public class Example {
    private static final int STATUS_VALUE = 0;
    private static final int FLAGGED = 4;
    private static final int NUMBER_OF_TASKS = 34;
    /**
     * 反例
     * 流逝的时间（以天为单位）
     */
    private int d;

    /**
     * 正例
     * 流逝的时间（以天为单位）
     */
    private int elapsedTimeInDays;

    private List<int[]> theList;
//    private List<int[]> gameBoard;
    private List<Cell> gameBoard;

    /**
     * getThem这个方法，模糊的地方有
     * 1、theList 代表什么
     * 2、theList 零下标条目的意义是什么
     * 3、值4的意义是什么
     * 4、我怎么使用返回的列表
     *
     * @return
     */
    public List<int[]> getThem() {
        List<int[]> them = new ArrayList<int[]>();
        for (int[] x : theList)
            if (x[0] == 4)
                them.add(x);
        return them;
    }

    /**
     * 优化
     * 获取被标记的单元格
     * @return
     */
//    public List<int[]> getFlaggedCells() {
//        List<int[]> flaggedCells = new ArrayList<>();
//        for (int[] cell : gameBoard)
//            if (cell[STATUS_VALUE] == FLAGGED)
//                flaggedCells.add(cell);
//        return flaggedCells;
//    }

    /**
     * 二次优化
     * @return
     */
    public List<Cell> getFlaggedCells() {
        List<Cell> flaggedCells = new ArrayList<Cell>();
        for (Cell cell : gameBoard)
            if (cell.isFlagged())
                flaggedCells.add(cell);
        return flaggedCells;
    }

    public void searchable() {
        int s = 0;
        int[] t = new int[4];
        for (int j = 0; j< 34; j++) {
            s += (t[j] * 4) / 5;
        }
        // VS
        int realDaysPerIdealDay = 4;
        int WORK_DAYS_PER_WEEK = 5;
        int[] taskEstimate = new int[10];
        int sum = 0;
        for (int j = 0; j < NUMBER_OF_TASKS; j++) {
            int realTaskDays = taskEstimate[j] * realDaysPerIdealDay;
            int realTaskWeeks = (realTaskDays / WORK_DAYS_PER_WEEK);
            sum += realTaskWeeks;
        }
    }

    private void printGuessStatistics(char candidate, int count) {
        String number;
        String verb;
        String pluralModifier;
        if (count == 0) {
            number = "no";
            verb = "are";
            pluralModifier = "s";
        } else if (count == 1) {
            number = "1";
            verb = "is";
            pluralModifier = "";
        } else {
            number = Integer.toString(count);
            verb = "arg";
            pluralModifier = "s";
        }
        String guessMessage = String.format(
                "There %s %s %s%s", verb, number, pluralModifier, candidate
        );
        System.out.println(guessMessage);
    }
}
